package com.chookss.view;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chookss.R;
import com.chookss.home.rank.RankEntity;
import com.chookss.tools.Utils;
import com.chookss.view.listener.ShareDialogListener;

import butterknife.BindView;

public class Rank2Dialog extends BaseDialog {

    @BindView(R.id.tvAttribution)
    TextView tvAttribution;
    @BindView(R.id.tvType)
    TextView tvType;
    @BindView(R.id.llType)
    LinearLayout llType;
    @BindView(R.id.tvPhone)
    TextView tvPhone;
    @BindView(R.id.llPhone)
    LinearLayout llPhone;
    @BindView(R.id.tvAccess)
    TextView tvAccess;
    @BindView(R.id.tvSource)
    TextView tvSource;
    @BindView(R.id.tvTime)
    TextView tvTime;
    @BindView(R.id.tvSure)
    TextView tvSure;
    @BindView(R.id.tvName)
    TextView tvName;
    @BindView(R.id.llName)
    LinearLayout llName;
    private Context context;
    private RankEntity rankEntity;
    private ShareDialogListener listener = null;

    public Rank2Dialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_rank2;
    }

    @Override
    protected void init(View view) {
        initCenter(0.3f);
        tvSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public Rank2Dialog(@NonNull Context context, int dayType, RankEntity rankEntity) {
        super(context);
        this.context = context;
        this.rankEntity = rankEntity;
        tvAttribution.setText(rankEntity.getRegion() + rankEntity.getCity());
        tvAccess.setText(rankEntity.getVisitNum());
        if(Utils.isNull(rankEntity.getNickname())){
            llName.setVisibility(View.GONE);
        }else{
            tvName.setText(rankEntity.getNickname());
            llName.setVisibility(View.VISIBLE);
        }
        tvTime.setText(Utils.getAccurateDate(rankEntity.getCreateTime()));
        tvSource.setText(rankEntity.getUserSource());
        if (dayType == 5) {
            llPhone.setVisibility(View.GONE);
            llType.setVisibility(View.VISIBLE);
            if ("0".equals(rankEntity.getUserType())) {
                tvType.setText("游客");
            } else if ("1".equals(rankEntity.getUserType())) {
                tvType.setText("粉丝");
            } else {
                tvType.setText("会员");
            }

        } else {
            llType.setVisibility(View.GONE);
            if (dayType == 2) {
                llPhone.setVisibility(View.VISIBLE);
                tvPhone.setText(rankEntity.getPhone());
            } else {
                llPhone.setVisibility(View.GONE);
            }

        }


    }
}
